<template>
    <div>
        <el-table :data="porps.list" style="width: 100%">
            <el-table-column v-if="type == 1" label="名字" prop="username" />
            <el-table-column prop="reason" label="请假理由" />
            <el-table-column label="开始时间">
                <template #default="scope">
                    {{ dayjs(scope.row.start).format("YYYY-MM-DD") }}
                </template>
            </el-table-column>
            <el-table-column label="结束时间">
                <template #default="scope">
                    {{ dayjs(scope.row.end).format("YYYY-MM-DD") }}
                </template>
            </el-table-column>
            <el-table-column prop="extend" label="附件" />
            <el-table-column label="审核结果">
                <template #default="scope">
                    <span v-if="type == 1">
                        <span v-if="scope.row.type === 1">
                            <el-button type="success" @click="ok(scope.row, 2)">同意</el-button>
                            <el-button type="danger" @click="ok(scope.row, 3)">拒绝</el-button>
                        </span>
                    </span>
                    <span v-if="type == 2">
                        <el-button type="warning" v-if="scope.row.type === 1">待审批</el-button>
                    </span>
                    <el-button type="success" v-if="scope.row.type === 2">已通过</el-button>
                    <el-button type="danger" v-if="scope.row.type === 3">已拒绝</el-button>
                </template>
            </el-table-column>
        </el-table>
    </div>
</template>

<script setup lang="ts">

import { defineProps } from 'vue';


import { dayjs } from 'element-plus'
import { patchLeveList } from '@/server/leveServer';


const porps = defineProps(['list', 'type'])

const ok = async (item: any, nowtype: number) => {
    console.log(item.type);
    console.log(nowtype);
    const { data } = await patchLeveList({ id: item._id, type: nowtype });
    if (data.code == 200) {
        item.type = nowtype
        console.log('a');

    }

}
const no = () => {
    // const res = await patchLeveList({ id, nowtype })

}


</script>

<style scoped>

</style>